#include int Power = 11; // Power pin for the NeoPixel int PIN = 12; // Data pin for the NeoPixel #define NUMPIXELS 1 int buttonPin = D1; // Pin D1 connected to the button Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); void setup() { pixels.begin(); pinMode(Power, OUTPUT); digitalWrite(Power, HIGH); pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor to avoid floating state } void loop() { if (digitalRead(buttonPin) == HIGH) { // Button is pressed, set color to white pixels.clear(); pixels.setPixelColor(0, pixels.Color(255, 255, 255)); // White color pixels.show(); delay(500); } else { // Cycle between red, green and blue pixels.clear(); pixels.setPixelColor(0, pixels.Color(0, 255, 0)); // Green color pixels.show(); delay(500); pixels.clear(); pixels.setPixelColor(0, pixels.Color(0, 0, 255)); // Blue color pixels.show(); delay(500); pixels.clear(); pixels.setPixelColor(0, pixels.Color(255, 0, 0)); // Red color pixels.show(); delay(500); } }